package com.qianxiwitdoctor.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qianxi.wit.pojo.TbDoctor;
import com.qianxi.wit.result.CodeMsg;
import com.qianxi.wit.result.R;
import com.qianxi.wit.result.Result;
import com.qianxiwitdoctor.service.DoctorServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * controller
 * @author Administrator
 *
 */
@RestController
@RequestMapping("/audit")
public class DoctorController {

	@Autowired
	private DoctorServiceImpl doctorServiceimpl;

	//医生审核列表
	@GetMapping("/auditList/{doctorStatus}/{hospitalId}/{doctorTime}/{pageNum}/{pageSize}")
	public R auditList(@PathVariable("doctorStatus")int doctorStatus,
					   @PathVariable("hospitalId")long hospitalId,
					   @PathVariable("doctorTime")Long doctorTime,
					   @PathVariable("pageNum")Long pageNum,
					   @PathVariable("pageSize")Long pageSize){
		try {
			Page<TbDoctor> page = doctorServiceimpl.auditList(doctorStatus,hospitalId,doctorTime,pageNum,pageSize);
			return R.ok().data("total",page.getTotal()).data("list",page.getRecords());
		}catch (Exception e){
			e.printStackTrace();
			return R.error();
		}
	}

	//修改状态
	@GetMapping("/doctorstatuc/{doctorId}/{status}")
	public R doctorstatuc(@PathVariable("doctorId")int doctorId,
							   @PathVariable("status")long status){
		try {
			doctorServiceimpl.doctorstatuc(doctorId,status);
			return R.ok();
		}catch (Exception e){
			e.printStackTrace();
			return R.error();
		}
	}

	//根据id查询详情
	@GetMapping("/findById/{doctorId}")
	public R findById(@PathVariable("doctorId") long doctorId){
		try {
			TbDoctor doctor = doctorServiceimpl.findById(doctorId);
			return R.ok().data("list",doctor);
		}catch (Exception e){
			e.printStackTrace();
			return R.error();
		}
	}
}
